package net.csdra.place.component;

import net.csdra.basis.service.ServiceBaseInterface;
import net.csdra.place.domain.ReservationPlace;
import net.csdra.place.component.form.CreateReservationPlace;
import net.csdra.place.component.form.UpdateReservationPlace;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import java.sql.Timestamp;
import java.util.List;

/**
 * Created by msf on 2018/1/29.
 */
public interface ReservationPlaceComponent extends ServiceBaseInterface<ReservationPlace, CreateReservationPlace, UpdateReservationPlace> {


    /**
     * 根据预约场馆ID、开始时间、结束时间获取有冲突的预约
     *
     * @param metaId
     * @param begin
     * @param end
     * @return
     */
    List<ReservationPlace> findAllByMetaIdAndBeGinAndEnd(String metaId, Timestamp begin, Timestamp end, String reservationState);

    int countByMetaIdAndBeginAndEndAndState(String metaId, Timestamp begin, Timestamp end, String reservationState);

    Page<ReservationPlace> findPageByMetaIdAndBeginAndEnd(String metaId, Timestamp begin, Timestamp end, String reservationState, Pageable pageable);


    /**
     * 根据DIstictId开始结束时间和状态获取预约
     *
     * @param districtId
     * @param begin
     * @param end
     * @param reservationState
     * @return
     */
    List<ReservationPlace> findAllByDistrictIdAndBeGinAndEnd(String districtId, Timestamp begin, Timestamp end, String reservationState);

    /**
     * 只计算一级
     *
     * @param districtId
     * @param begin
     * @param end
     * @param reservationState
     * @return
     */
    int countByDistrictIdAndBeginAndEndAndState(String districtId, Timestamp begin, Timestamp end, String reservationState);


    /**
     * 计算本级和所有子级的总和
     *
     * @param districtId
     * @param begin
     * @param end
     * @param reservationState
     * @return
     */
    int countAllByDistrictIdAndBeginAndEndAndState(String districtId, Timestamp begin, Timestamp end, String reservationState);

    Page<ReservationPlace> findPageByDistrictIdAndBeginAndEnd(String districtId, Timestamp begin, Timestamp end, String reservationState, Pageable pageable);


}
